;simple_retail Installer Script

;--------------------------------
;Include Modern UI

  !include "MUI.nsh"

;--------------------------------
;General

  SetCompress force
  
  SetCompressor lzma
  
  ;Name and file
  Name "simple_retail"
  OutFile "dist/simple_retailInstaller.exe"

  ;Default installation folder
  InstallDir "$PROGRAMFILES\Ayuku IT Solutions\simple_retail"
  
  ;Get installation folder from registry if available
  InstallDirRegKey HKCU "Software\simple_retail" ""
   
   ;set comppression
   
;--------------------------------
;Interface Settings

  !define MUI_ABORTWARNING
	!define MUI_HEADERIMAGE ".\nsis\installersplash.bmp"
	!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
	!define MUI_HEADERIMAGE_BITMAP ".\nsis\installersplash.bmp"
	!define MUI_ICON ".\nsis\install.ico"
	!define MUI_UNICON ".\nsis\uninstall.ico"

;--------------------------------
;Pages

  !insertmacro MUI_PAGE_LICENSE ".\nsis\license.txt"
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES

  	!define MUI_FINISHPAGE_RUN
	!define MUI_FINISHPAGE_RUN_TEXT "Run simple_retail?"
	!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
	!insertmacro MUI_PAGE_FINISH
  
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "simple_retail (required)" SecDummy

  SectionIn RO

  ;Files to be installed
  SetOutPath "$INSTDIR"
  
   File "dist\simple_retail.exe"
   File "launch4j\icon.ico"
   File "dist\server.ini"

   SetOutPath "$INSTDIR\lib"
   File "dist\lib\lib.jar"
   File "dist\lib\db.jar"
 
   SetOutPath "$INSTDIR\db"
   File "D:\MY_DREAM_JAVA_DB\h2\service\data\simpleretail\simpleretail.h2.db"
  
   SetOutPath "$INSTDIR"  
   FILE /r "jre"
 
  ;SetOutPath "$INSTDIR\jre"
  

    ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\simple_retail "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\simple_retail" "DisplayName" "simple_retail"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\simple_retail" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\simple_retail" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\simple_retail" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
  CreateDirectory "$SMPROGRAMS\simple_retail"
  CreateShortCut "$SMPROGRAMS\simple_retail\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe"
  CreateShortCut "$SMPROGRAMS\simple_retail\simple_retail.lnk" "$INSTDIR\simple_retail.exe" "" "$INSTDIR\icon.ico"
SectionEnd

;--------------------------------
;Uninstaller Section

Section "Uninstall"

  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\simple_retail"
  DeleteRegKey HKLM SOFTWARE\simple_retail
  DeleteRegKey /ifempty HKCU "Software\simple_retail"

	; Remove shortcuts
  RMDir /r "$SMPROGRAMS\simple_retail"

  ; Remove directories used
  RMDir /r "$INSTDIR"

SectionEnd

Function LaunchLink
  ExecShell """$SMPROGRAMS\simple_retail\simple_retail.lnk"
FunctionEnd



